﻿-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE SaveListing 
	-- Add the parameters for the stored procedure here
  	   @PopertyId VARCHAR(50),
	   @ListTypeId INT,
       @StateId VARCHAR(50),
       @LocationId VARCHAR(50),
       @RoadId VARCHAR(50),
       @ProjectId VARCHAR(50)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;
	DECLARE @CurrentDate DATETIME
	SET @CurrentDate = GetDate()
	IF (@PopertyId =0)
		BEGIN 
			DECLARE @PropertyId UNIQUEIDENTIFIER
			SET @PropertyId = NEWID()
			-- Insert statements for procedure here
			INSERT INTO AW_Property (PropertyId, RoadId, ProjectId, ListType, CreateDate,PropertyTypeId, UnitNumber) VALUES (@PropertyId,@RoadId,@ProjectId, @ListTypeId, @CurrentDate,'6D8B8ED4-7DB8-4C95-BC97-041BDFCDA69B',1)
		END
	ELSE
		BEGIN
			UPDATE AW_Property SET RoadId=@RoadId, ProjectId=@ProjectId, ListType=@ListTypeId WHERE PropertyId=@PropertyId
			
		END

	SELECT @PropertyId 

END
